<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Window resize example</title>
    <style>
      body {
        margin: 0;
      }

      div {
        box-sizing: border-box;
        width: 100px;
        height: 100px;
        background-image: url(bgtile.png);
        border: 10px solid white;
      }
    </style>
  </head>
  <body>

    <div>

    </div>

    <script>
      const div = document.querySelector('div');
      let winWidth = window.innerWidth;
      let winHeight = window.innerHeight;

      div.style.width = winWidth + 'px';
      div.style.height = winHeight + 'px';

      window.onresize = function() {
        winWidth = window.innerWidth;
        winHeight = window.innerHeight;
        div.style.width = winWidth + 'px';
        div.style.height = winHeight + 'px';
      }
    </script>
  </body>
</html>
